Ensure transient key dependencies are applied #29
+319
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When one entity's key references another entity's key transitively, and the object in-between is a value type, the compound key for the referenced entity is not created correctly.
Observed result
Here's an example schema:
This is the node-froid schema that would currently be generated:
Note that
Foo
doesn't get a compound key whereFoo.bar.baz
includes thebazId
field. This means node-froid is failing to find the transient dependency.Expected result
The intended schema should be:
Note the
bazId
in the key.Cause and fix
If we add a key to
Bar
like so:Then the transient dependency is honored:
This points to the value type breaking the inheritance of keys. This PR solves the problem, allowing the transient key dependencies to pass through value types resulting in the desired schema:
To achieve this, we calculate keys based on dependencies for value types so the transient dependencies can be determined and skip applying the keys to the value types when we output their final schema. So, essentially, all objects get keys, but we only include keys on entities in the actual schema.
Type of Change
Checklist
contributing guidelines